package com.Tadama.Forms;

import com.Tadama.MIDlet.TadamaMIDlet;
import com.Tadama.Utility.CommandBuilder;
import java.io.IOException;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextField;

public class frmBuscarClientes extends Form implements CommandListener{
    private Displayable previousDisplay;
    private TadamaMIDlet mainMIDlet;
    private lstClientes ListaClientes;
    
    private TextField tfCriterio;
    private ChoiceGroup chgCriterios;
    private static final String[]MENU_ITEMS={"Nombre/Rzn. Social", "RUC/DNI"};
    private static final Command cmCancelar = CommandBuilder.getCancel();
    private static final Command cmBuscar = CommandBuilder.getBuscar();
    
    
    public frmBuscarClientes(String title,TadamaMIDlet mainMIDlet,Displayable previousDisplay) {
        super(title.trim());
        this.mainMIDlet= mainMIDlet;
        this.previousDisplay= previousDisplay;
        init();
    }

    public frmBuscarClientes(String title) {super(title);}
    
    private void init() {
        chgCriterios = new ChoiceGroup("Busquecar por", Choice.POPUP, MENU_ITEMS, null);
        chgCriterios.setSelectedFlags(new boolean[]{false, false});
        tfCriterio= new TextField("Criterio", "Bodega P", 20,TextField.ANY);
        this.append(chgCriterios);
        this.append(tfCriterio);        
        this.addCommand(cmBuscar);
        this.addCommand(cmCancelar);
        this.setCommandListener(this);
    }
    
    public void commandAction(Command c, Displayable d) {
        if (d == this) {
            if (c == cmBuscar) {
                Display.getDisplay(mainMIDlet).setCurrent(new frmWaitScreem(getDisplay(),mainMIDlet,this,1));
                //getWaitScreen();
            }
        }
    }
    
    public Display getDisplay() { return Display.getDisplay(mainMIDlet); }
    
    private static Image loadImage(String name) {
        Image image = null;
        try {
            image = Image.createImage(name);
        }catch (IOException ioe){
            System.out.println(ioe);
    }
    return image;
  }
    
    public void getInfoClientes() {
        //Display.getDisplay(mainMIDlet).setCurrent(getAlert(), getDisplay());
    }
}